#include "pagebutton.h"

PageButton::PageButton(int page, QWidget* parent)
    :QPushButton(parent)
{
    this->page = page;
    // 设置按钮的图标尺寸和按钮大小
    setFixedSize(32, 32);
    setIconSize(QSize(16, 16));

    // 设置按钮上显示文本
    if(this->isFoldedBtn) {
        this->setText("...");
    } else {
        this->setText(QString::number(page));
    }
    // 设置按钮为是否选中状态
    this->setActive(this->isActiveBtn);
}

void PageButton::setActive(bool active)
{
    this->isActiveBtn = active;
    if (active) {
        this->setStyleSheet("QPushButton {"
                            "color: #FFFFFF; "
                            "background-color: #3ECEFE; "
                            "border: 1px solid #3ECEFE; "
                            "border-radius: 2px;}");
    } else {
        this->setStyleSheet("QPushButton {"
                            "color: #000000; "
                            "background-color: #FFFFFF; "
                            "border: 1px solid #D9D9D9; "
                            "border-radius: 2px;}");
    }
}

void PageButton::setFolded(bool folded)
{
    this->isFoldedBtn = folded;
    if(folded) {
        this->setText("...");
    } else {
        this->setText(QString::number(page));
    }
}

void PageButton::setPage(int page)
{
    this->page = page;
    this->setText(QString::number(page));
}

int PageButton::getPage() const
{
    return this->page;
}

bool PageButton::isActived() const
{
    return this->isActiveBtn;
}

bool PageButton::isFolded() const
{
    return this->isFoldedBtn;
}
